<template>
  <page-meta :root-font-size="fontsize" style="display: block">
    <div class="page userAgreement">
      <xlNavBar :isShare="isShare" :title="title" bgc="ff9d49"></xlNavBar>
      <div class="content" v-html="content"></div>
    </div>
  </page-meta>
</template>

<script>
export default {
  name: "userAgreement",
  components: {},
  props: {
    type: {
      type: String,
      default: "yhxy"
    }
  },
  data() {
    return {
      isShare: 0,
      fontsize: "",
      $pageName: "用户协议",
      title: "用户协议",
      name: "111",
      content: ""
    };
  },
  computed: {},
  methods: {
    async getDetail(type) {
      let url = "";
      // if (type == "job") {
      //   url = "/jobs/agreement";
      // } else {
      //   url = "/resumes/agreement";
      // }
      switch (type) {
        case "job":
          url = "/jobs/agreement";
          this.title = "招聘协议";
          break;
        case "resume":
          url = "/resumes/agreement";
          this.title = "求职协议";
          break;
        case "yhczxy":
          url = "/bills/agreement";
          this.title = "用户充值协议";
          break;
        case "yhxy":
          url = "/bills/agreement";
          this.title = "用户协议";
          break;
      }
      let res = await this.$http.requestSync(url);

      if (res.code == 200) {
        this.content = res.agreement;
      }
    }
  },
  watch: {},

  // 页面周期函数--监听页面加载
  onLoad(options) {
    if (options.params) {
      let params = JSON.parse(decodeURIComponent(options.params));
      if (params.shareUserId) {
        this.$setStoraged("shareUserId", params.shareUserId);
        this.isShare = 1;
      }
    }
    this.getDetail(options.type || "job");
    let designWidth = 37.5; //因设计图的宽度
    let that = this;
    //窗体改变大小触发事件
    uni.onWindowResize((res) => {
      console.log("变化后的窗口宽度=", res.size.windowWidth);
      //100*屏幕宽度/设计稿宽度
      that.fontsize =
        Math.floor((1.5 * res.size.windowWidth) / designWidth) + "px";
      console.log("字体大小：", that.fontsize);
    });

    //打开获取屏幕大小
    uni.getSystemInfo({
      success(res) {
        console.log("设备信息：", res);
        that.fontsize =
          Math.floor((1.5 * res.screenWidth) / designWidth) + "px";
        console.log("字体大小：", that.fontsize);
      }
    });
  },
  // 页面周期函数--监听页面初次渲染完成
  onReady() {},
  // 页面周期函数--监听页面显示(not-nvue)
  onShow() {},
  // 页面周期函数--监听页面隐藏
  onHide() {},
  // 页面周期函数--监听页面卸载
  onUnload() {}
  // 页面处理函数--监听用户下拉动作
  // onPullDownRefresh() { uni.stopPullDownRefresh(); },
  // 页面处理函数--监听用户上拉触底
  // onReachBottom() {},
  // 页面处理函数--监听页面滚动(not-nvue)
  // onPageScroll(event) {},
  // 页面处理函数--用户点击右上角分享
  // onShareAppMessage(options) {},
};
</script>

<style scoped lang="scss">
.userAgreement {
  background: #f7f7f7;
  width: 100vw;
  height: 100vh;
  .content {
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    background: #ffffff;
    border-radius: 10px;
    opacity: 1;
    margin: 10px auto;
    overflow: auto;
    box-sizing: border-box;
    padding: 12px;
  }
}
</style>
